package com.lqfan.autoAnswerQ.dao.notebook;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lqfan.autoAnswerQ.model.notebook.myNote;
import com.lqfan.autoAnswerQ.model.subject.Subject;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 笔记本的接口
 * </p>
 *
 * @author zmlin
 * @since 2020-04-11
 */

@Mapper
public interface NoteBookMapper extends BaseMapper<myNote> {

    @Insert("insert into myNote (id,userId,subjectId,noteContent) values(#{id},#{userId},#{subjectId},#{noteContent})")
    @Options(useGeneratedKeys = true,keyProperty = "id" , keyColumn = "id")
    int insertNoteBook(myNote myNote);

    @Select("select s.* from myNote m,subject s where m.userId =#{userId} and s.id=m.subjectId group by m.subjectId")
    List<Subject> getSubjectNote(String userId);
//    @Delete("delete from myNote where userId=#{userId} and id = #{id}")
//    @Options(useGeneratedKeys = true,keyProperty = "id" , keyColumn = "id")
//    boolean deleteNote(myNote myNote);

}
